/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.Color;
import javax.swing.JApplet;

/**
 *
 * @author sewardn
 */
public class TurtleAppletTest extends JApplet implements Runnable {

    public void init()
    {
        Turtle.startApplet(this);
    }

    public void forward(Turtle t)
    {
       t.forward(10);
    }

    public void left(Turtle t)
    {
       t.left(10);
    }

    public void right(Turtle t)
    {
       t.right(10);
    }

    public void zoomFit(Turtle t)
    {
       Turtle.zoomFit();
    }

    public void undo(Turtle t)
    {
       t.undo();
    }

    public void redo(Turtle t)
    {
       t.redo();
    }

    public void rcolor(Turtle t,String key)
    {
        int r=(int)(Math.random()*255);
        int g=(int)(Math.random()*255);
        int b=(int)(Math.random()*255);
        if(key.equals("a")) Turtle.bgcolor(new Color(r,g,b));
        if(key.equals("w")) t.penColor(new Color(r,g,b));
        if(key.equals("s")) t.outlineColor(new Color(r,g,b));
        if(key.equals("d")) t.fillColor(new Color(r,g,b));
    }

    public void run()
    {
        Turtle t=new Turtle();
        t.onKey("rcolor", "a", false, true);
        t.onKey("rcolor", "s", false, true);
        t.onKey("rcolor", "d", false, true);
        t.onKey("rcolor", "w", false, true);
        t.onKey("forward", "up", true, true);
        t.onKey("left", "left", true, true);
        t.onKey("right", "right", true, true);
        t.onKey("zoomFit", "z", true, true);
        t.onKey("undo", "u", true, true);
        t.onKey("redo", "r", true, true);
    }


}
